<?php
namespace Singleton;

/**
* 单例模式
*/
class Singleton
{
    private static $_instance;

    private function __construct()
    {
        # code...
    }

    /**
     * 禁止clone对象
     * @return string
     */
    public function __clone()
    {
        echo 'clone is forbidden';
    }

    public static function getInstance()
    {
        if (!self::$_instance instanceof self) {
            self::$_instance = new self;
        }

        return self::$_instance;
    }

    public function test()
    {
        echo '这是个测试' . PHP_EOL;
    }
}